import React, { Component } from 'react'

import { PickerView } from 'antd-mobile'

import FilterFooter from '../../../../components/FilterFooter'

export default class FilterPicker extends Component {
  constructor(props) {
    super(props)
    this.state = {
      value: this.props.defaultValue,
    };
  }
 
  onChange = (value) => {
    this.setState({
      value,
    });
  }

  render() {
    const {onCancel,onSave,data,cols,type} = this.props

    return (
      <>
      {/* 选择器组件 */}
        <PickerView
          data={data}
          value={this.state.value}
          cols={cols}
          onChange={this.onChange}
        />
        {/* 底部按钮 */}
        <FilterFooter onCancel={()=>onCancel(type) } onSave={()=>onSave(type,this.state.value)}
        />
      </>
    )
  }
}
